// import { useStorage } from '@vueuse/core'
import artTemplate from "art-template"
import dot from "dot"
import dayjs from "dayjs"
import _ from "lodash"

/**
 * 多模板渲染
 */
export function render(name, source, data) {
  try {
    switch (name) {
      case "art"     : return artTemplate.render(source, data, {imports: {dayjs, _}, debug: true})
      case "lodash"  : return _.template(source, {imports: {dayjs}})(data)
      case "dot"     : return dot.template(source)({dayjs, _, ...data})
      default        : return `${name} 模板引擎暂不支持`
    }
  } catch (e) {
    return `${name}模板报错: ${e}`
  }
}